package com.Lixiaoqian.CardPlay.utils;

import android.content.Context;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.Lixiaoqian.CardPlay.R;

import static android.icu.lang.UCharacter.GraphemeClusterBreak.T;


/**
 * Created by HuangZhiBo on 2017/2/20/020.
 * email:1043202454@qq.com
 */

public class ToastUtils {
    private ToastUtils() {
            /* cannot be instantiated */
        throw new UnsupportedOperationException("cannot be instantiated");
    }

    public static boolean isShow = true;

    /**
     * 短时间显示Toast
     *
     * @param context
     * @param message
     */
    public static void showShort(Context context, String message) {
        if (isShow)
            toast(message, context);
    }


    /**
     * 长时间显示Toast
     *
     * @param context
     * @param message
     */
    public static void showLong(Context context, String message) {
        if (isShow)
            toast(message, context);
    }


    private static void toast(String message, Context context) {
        View toastRoot = LayoutInflater.from(context).inflate(R.layout.layout_toast, null);
        Toast toast = new Toast(context);
        toast.setView(toastRoot);
        TextView tv = (TextView) toastRoot.findViewById(R.id.toast_notice);
        tv.setText(message);
        toast.setGravity(Gravity.BOTTOM, 0, 230);
        toast.setDuration(Toast.LENGTH_SHORT);
        toast.show();
    }
}
